<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>作业v-for和v-bind的结合</title>
</head>
<style>
  .fontColor {
    color: red;
  }
</style>
<body>
<!--作业需求：点击列表中的哪一项，那么该项的文字变成红色-->
<div id="app">
  <ul>
    <!--两种方式-->
    <!--1、-->
    <!--<li v-for="(movie,index) in movies" :class="{fontColor:count == index}" @click="change(index)" >{{movie}}</li>-->
    <!--2、-->
    <li v-for="(movie,index) in movies" :class="count == index ? 'fontColor' :''" @click="change(index)">{{movie}}</li>
  </ul>
</div>
<script src="../js/vue.js"></script>
<script>
  const app = new Vue({
    el: '#app',
    data: {
      movies: ['海王', '海尔兄弟', '火影忍者', '进击的巨人'],
      count: -1
    },
    methods: {
      change: function (index) {
        this.count = index;
      }
    }
  });
</script>
</body>
</html>
